define(["jquery", "easy-admin"], function ($, ea) {

    var init = {
        table_elem: '#currentTable',
        table_render_id: 'currentTableRenderId',
        index_url: 'mall.tickets/index',
        add_url: 'mall.tickets/add',
        edit_url: 'mall.tickets/edit',
        delete_url: 'mall.tickets/delete',
        export_url: 'mall.tickets/export',
        modify_url: 'mall.tickets/modify',
        stock_url: 'mall.tickets/stock',
    };

    var Controller = {

        index: function () {
            ea.table.render({
                init: init,
                toolbar: ['refresh',
                    [{
                        text: '添加',
                        url: init.add_url,
                        method: 'open',
                        auth: 'add',
                        class: 'layui-btn layui-btn-normal layui-btn-sm',
                        icon: 'fa fa-plus ',
                        extend: 'data-full="true"',
                    }],
                    'delete', 'export'],
                cols: [[
                    { type: "checkbox" },
                    { field: 'id', width: 80, title: 'ID' },
                    { field: 'sort', width: 80, title: '排序', edit: 'text' },
                    { field: 'cate.title', minWidth: 80, title: '商品分类' },
                    { field: 'tickets_name', minWidth: 80, title: '票务名称' },
                    { field: 'market_price', width: 100, title: '门票市场价', templet: ea.table.price },
                    { field: 'discount_price', width: 100, title: '门票折扣价', templet: ea.table.price },
                    { field: 'describe', width: 100, title: '描述' },
                    { field: 'limit_count', width: 100, title: '限购数量' },
                    {
                        width: 250,
                        title: '操作',
                        templet: ea.table.tool,
                        operat: [
                            [{
                                text: '编辑',
                                url: init.edit_url,
                                method: 'open',
                                auth: 'edit',
                                class: 'layui-btn layui-btn-xs layui-btn-success',
                                extend: 'data-full="true"',
                            },

                            ],
                            'delete']
                    }
                ]],
            });

            ea.listen();
        },
        add: function () {
            ea.listen();
        },
        edit: function () {
            ea.listen();
        },
        stock: function () {
            ea.listen();
        },
    };
    return Controller;
});